


#ifndef PF_POINT_H
#define PF_POINT_H

#include "pf_atomicentity.h"
#include "lx_Export.h"


/**
 * Holds the data that defines a point.
 */
class LX_EXPORT PF_PointAttribute {
public:
    PF_PointAttribute(const PF_Vector& pos) {
        this->pos = pos;
    }

    friend std::ostream& operator << (std::ostream& os, const PF_PointAttribute& pd) {
        os << "(" << pd.pos << ")";
        return os;
    }

    PF_Vector pos;
};



/**
 * Class for a point entity.
 *

 */
class LX_EXPORT PF_Point : public PF_AtomicEntity {
public:
    PF_Point(PF_Container* parent,
             const PF_PointAttribute& d);

    virtual PF_Entity* clone() {
        PF_Point* p = new PF_Point(*this);
        p->initId();
        return p;
    }

    /**	@return PF_ENTITY_POINT */
    virtual LX_Define::EntityType rtti() const {
        return LX_Define::EntityPoint;
    }
	
    /** 
	 * @return Start point of the entity. 
	 */
    virtual PF_Vector getStartpoint() const {
        return data.pos;
    }
    /** 
	 * @return End point of the entity. 
	 */
    virtual PF_Vector getEndpoint() const {
        return data.pos;
    }

	virtual void moveStartpoint(const PF_Vector& pos);

    /** @return Copy of data that defines the point. */
    PF_PointAttribute getData() const {
        return data;
    }

    virtual PF_VectorSolutions getRefPoints();

    /** @return Position of the point */
    PF_Vector getPos() {
        return data.pos;
    }

    /** Sets a new position for this point. */
    void setPos(const PF_Vector& pos) {
        data.pos = pos;
    }

    virtual PF_Vector getNearestEndpoint(const PF_Vector& coord,
                                         double* dist = NULL);
    virtual PF_Vector getNearestPointOnEntity(const PF_Vector& coord,
            bool onEntity = true, double* dist = NULL, PF_Entity** entity = NULL);
    virtual PF_Vector getNearestCenter(const PF_Vector& coord,
                                       double* dist = NULL);
    virtual PF_Vector getNearestMiddle(const PF_Vector& coord,
                                       double* dist = NULL);
    virtual PF_Vector getNearestDist(double distance,
                                     const PF_Vector& coord,
                                     double* dist = NULL);
    virtual double getDistanceToPoint(const PF_Vector& coord,
                                      PF_Entity** entity=NULL,
                                      LX_Define::ResolveLevel level=LX_Define::ResolveNone,
									  double solidDist = LX_DOUBLEMAX);

    virtual void move(PF_Vector offset);
    virtual void rotate(PF_Vector center, double angle);
    virtual void scale(PF_Vector center, PF_Vector factor);
    virtual void mirror(PF_Vector axisPoint1, PF_Vector axisPoint2);

    virtual void draw(PF_Painter* painter, PF_GraphicView* view, double patternOffset=0.0);

    friend std::ostream& operator << (std::ostream& os, const PF_Point& p);

    /** Recalculates the borders of this entity. */
    virtual void calculateBorders ();

protected:
    PF_PointAttribute data;
    //PF_Vector point;
}
;

#endif
